import 'package:changxindianzishangwu/util/colors.dart';
import 'package:flutter/material.dart';

class DefCheckBoxWidget extends StatefulWidget {
  DefCheckBoxWidget(
      {Key key, @required this.value, @required this.onTap, this.right = 8})
      : super(key: key);

  final bool value;
  final onTap;
  double right;
  @override
  State<StatefulWidget> createState() {
    return DefCheckBoxWidgetBuilder();
  }
}

class DefCheckBoxWidgetBuilder extends State<DefCheckBoxWidget> {
  Widget build(BuildContext context) {
    return InkWell(
      child: Container(
        width: 22,
        height: 22,
        margin: EdgeInsets.only(right: width(widget.right)),
        decoration: BoxDecoration(
            color: widget.value
                ? ZdColor.rgba(0, 220, 169, 1)
                : ZdColor.rgba(0, 0, 0, 0.5),
            borderRadius: BorderRadius.circular(22)),
        child: Center(
          child: Icon(
            Icons.check,
            color: Color(0xffffffff),
            size: 16,
          ),
        ),
      ),
      onTap: () {
        widget.onTap(!widget.value);
      },
    );
  }
}
